<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      function shellSort(arr) {
        let len = arr.length;
        for (let gap = Math.floor(len / 2); gap > 0; gap = Math.floor(gap / 2)) {
          for (let i = gap; i < len; i++) {
            let j = i;
            let current = arr[i];
            while (j - gap >= 0 && current < arr[j - gap]) {
              arr[j] = arr[j - gap];
              j = j - gap;
            }
            arr[j] = current;
          }
        }
        return arr;
      }
      console.log(shellSort([1, 3, 5, 2, 4, 10]));
    </script>
  </body>
</html>
